import { createRouter, createWebHashHistory } from 'vue-router'
// import { setupLayouts } from 'virtual:generated-layouts'
// import generatedRoutes from 'virtual:generated-pages'

// let routes = []
// generatedRoutes.forEach(v => {
//   routes.push(v?.meta?.layout != false ? setupLayouts([v])[0] : v)
// })


export default createRouter({
  history: createWebHashHistory(), //路由的模式
  linkExactActiveClass: 'active',  //点击路由跳转的底部样式标量
  routes: [
    { path: '/', redirect: '/login' },
    {
      path: '/login',
      name: 'login',
      component: () => import('@/components/Login.vue'),
      meta: { auth: false }  // 不需要登录
    },
    {
      path: '/register',
      name: 'register',
      component: () => import('@/components/Register.vue'),
      meta: { auth: false }  // 不需要登录
    },
    {
      path: '/index',
      name: 'index',
      component: () => import('@/components/Index.vue'),
      meta: { auth: false }  // 不需要登录
    },
    {
      path: '/detail/:id',
      name: 'detail',
      component: () => import('@/components/Detail.vue'),
      meta: { auth: true }  // 需要登录
    },
    {
      path: '/search',
      name: 'search',
      component: () => import('@/components/Search.vue'),
      meta: { auth: true }  // 需要登录
    },
    {
      path: '/cart',
      name: 'cart',
      component: () => import('@/components/Cart.vue'),
      meta: { auth: true }  // 需要登录
    },
    {
      path: '/about',
      name: 'about',
      component: () => import('@/components/About.vue'),
      meta: { auth: true }  // 需要登录
    },
    {
      path: '/searchkey',
      name: 'searchkey',
      component: () => import('@/components/SearchKey.vue'),
      meta: { auth: true }  // 需要登录
    },
    {
      path: '/settlement',
      name: 'settlement',
      component: () => import('@/components/Settlement.vue'),
      meta: { auth: true }  // 需要登录
    },
    {
      path: '/address',
      name: 'address',
      component: () => import('@/components/Address.vue'),
      meta: { auth: true }  // 需要登录
    },
    {
      path: '/addressEdit',
      name: 'addressEdit',
      component: () => import('@/components/AddressEdit.vue'),
      meta: { auth: true }  // 需要登录
    },
    {
      path: '/addressAdd',
      name: 'addressAdd',
      component: () => import('@/components/AddressAdd.vue'),
      meta: { auth: true }  // 需要登录
    },
    {
      path: '/coupon',
      name: 'coupon',
      component: () => import('@/components/Coupon.vue'),
      meta: { auth: true }  // 需要登录
    },
    {
      path: '/couponInfo',
      name: 'couponInfo',
      component: () => import('@/components/CouponInfo.vue'),
      meta: { auth: true }  // 需要登录
    },
    {
      path: '/myOrderList',
      name: 'myOrderList',
      component: () => import('@/components/MyOrderList.vue'),
      meta: { auth: true }  // 需要登录
    },
    {
      path: '/orderInfo',
      name: 'orderInfo',
      component: () => import('@/components/OrderInfo.vue'),
      meta: { auth: true }  // 需要登录
    },
    {
      path: '/orderRecord',
      name: 'orderRecord',
      component: () => import('@/components/OrderRecord.vue'),
      meta: { auth: true }  // 需要登录
    },
    {
      path: '/refund',
      name: 'refund',
      component: () => import('@/components/Refund.vue'),
      meta: { auth: true }  // 需要登录
    },
    {
      path: '/expressInfo',
      name: 'expressInfo',
      component: () => import('@/components/ExpressInfo.vue'),
      meta: { auth: true }  // 需要登录
    },
    {
      path: '/forgetPassword',
      name: 'forgetPassword',
      component: () => import('@/components/ForgetPassword.vue'),
      meta: { auth: false }  // 不需要登录
    },
    {
      path: '/editMy',
      name: 'editMy',
      component: () => import('@/components/EditMy.vue'),
      meta: { auth: true }  // 需要登录
    },
  ]
})
